import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '姓名',
    align:"center",
    dataIndex: 'fullName'
   },
   {
    title: '电话号码',
    align:"center",
    dataIndex: 'phoneNumber'
   },
   {
    title: '小区名称',
    align:"center",
    dataIndex: 'communityName'
   },
   {
    title: '楼栋号',
    align:"center",
    dataIndex: 'buildingNumber'
   },
   {
    title: '单元（区）',
    align:"center",
    dataIndex: 'unitArea'
   },
   {
    title: '门牌号',
    align:"center",
    dataIndex: 'houseNumber'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '姓名',
    field: 'fullName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入姓名!'},
          ];
     },
  },
  {
    label: '电话号码',
    field: 'phoneNumber',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入电话号码!'},
                 { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
          ];
     },
  },
  {
    label: '小区名称',
    field: 'communityName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入小区名称!'},
          ];
     },
  },
  {
    label: '楼栋号',
    field: 'buildingNumber',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入楼栋号!'},
                 { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'},
          ];
     },
  },
  {
    label: '单元（区）',
    field: 'unitArea',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入单元（区）!'},
          ];
     },
  },
  {
    label: '门牌号',
    field: 'houseNumber',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入门牌号!'},
          ];
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  fullName: {title: '姓名',order: 0,view: 'text', type: 'string',},
  phoneNumber: {title: '电话号码',order: 1,view: 'text', type: 'string',},
  communityName: {title: '小区名称',order: 2,view: 'text', type: 'string',},
  buildingNumber: {title: '楼栋号',order: 3,view: 'text', type: 'string',},
  unitArea: {title: '单元（区）',order: 4,view: 'text', type: 'string',},
  houseNumber: {title: '门牌号',order: 5,view: 'number', type: 'number',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}